<template>
  <div>
    <SearchAndTable
      :searchData="searchData"
      :operateData="[]"
      :columns="columns"
      :getTableData="getTableData"
      ref="table"
    />
    <!-- <Dialog :show="dialogShow" @ok="dialogShow = false" @cancel="dialogShow = false">
      <EditForm :infos="infos" :submitShow="false" />
      <div style="padding: 0 10px">
        <Button type="primary">下载</Button>
      </div>
    </Dialog> -->
  </div>
</template>

<script>
import SearchAndTable from '@/components/SearchAndTable/index'
import EditForm from '@/components/EditForm/index'
import Dialog from '@/components/Dialog/index'
import { systemHistoryList as getTableData, baseUrl } from '@/api/app'
export default {
  name: 'systemHistory',
  components: {
    SearchAndTable,
    Dialog,
    EditForm
  },
  data () {
    return {
      dialogShow: false,
      currentInfo: {},
      searchData: [
        // {
        //   label: '用户名',
        //   labelWidth: 100,
        //   key: 'userID'
        // },
        {
          label: '基站名',
          labelWidth: 100,
          key: 'stationName'
        },
        {
          label: '工程编号',
          labelWidth: 100,
          key: 'projectID'
        },
      ],
      columns: [
        {
          title: '工程编号',
          align: 'center',
          minWidth: 120,
          key: 'projectID'
        },
        {
          title: '基站名称',
          align: 'center',
          minWidth: 120,
          key: 'stationName'
        },
        {
          title: '操作人',
          align: 'center',
          minWidth: 120,
          key: 'userID'
        },
        {
          title: '创建时间',
          align: 'center',
          minWidth: 150,
          key: 'createTime'
        },
        {
          title: '图纸路径',
          align: 'center',
          minWidth: 120,
          key: 'cadPath'
        },
        {
          title: 'execl路径',
          align: 'center',
          minWidth: 150,
          key: 'excelPath'
        },
        {
          title: '操作',
          align: 'center',
          fixed: 'right',
          width: 120,
          render: (h, { row }) =>
            h('a',
              {
                attrs: {
                  href: `${baseUrl}/file/downloadFile?path=${encodeURIComponent(row.cadPath)}`,
                  download: new Date().getTime() + '.dxf'
                }
              },
              [
                h(
                  'Button',
                  {
                    props: {
                      type: 'primary',
                      size: 'small'
                    }
                  },
                  '重新下载'
                )
              ])
        }
      ],
      infos: [
        {
          label: '姓名',
          key: 'name',
          rules: true
        },
        {
          label: '手机号',
          key: 'phone',
          rules: true
        }
      ]
    }
  },
  methods: {
    async getTableData (page, size) {
      // "userID":"","projectID":"","stationName":"","page":1,"size":20
      let res = await getTableData(page, size)
      if (res.data) {
        let { content: data, total } = res.data
        return { data, total }
      } else {
        this.$Message.error(res.message)
        return { data: [], total: 0 }
      }
    }
  }
}
</script>
